package com.smartwebx.ha.dal.usebean;

import java.io.Serializable;
import java.util.Date;

import com.google.common.base.Objects;
import com.smartwebx.ha.dal.usebean.abstr.AbstractTm;
import com.smartwebx.ha.dal.usebean.abstr.AbstractValue;

/**
 * 过程对象
 * 
 * @author tsing
 * 
 */
public class DateValue implements AbstractValue, AbstractTm, Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Date tm;
	private Double val;

	public DateValue() {
		super();
	}

	public DateValue(Date tm, Double val) {
		super();
		this.tm = tm;
		this.val = val;
	}

	public Date getTm() {
		return tm;
	}

	public void setTm(Date tm) {
		this.tm = tm;
	}

	public Double getVal() {
		return Objects.firstNonNull(val, 0d);
	}

	public void setVal(Double val) {
		this.val = val;
	}

	@Override
	public int hashCode() {
		return Objects.hashCode(super.hashCode(), tm, val);
	}

	@Override
	public boolean equals(Object object) {
		if (object instanceof DateValue) {
			if (!super.equals(object))
				return false;
			DateValue that = (DateValue) object;
			return Objects.equal(this.tm, that.tm)
					&& Objects.equal(this.val, that.val);
		}
		return false;
	}

	@Override
	public String toString() {
		return Objects.toStringHelper(this).add("super", super.toString())
				.add("tm", tm).add("val", val).toString();
	}

	public static DateValue getDefDv() {
		return new DateValue(null, 0d);
	}

}